{extend name="admin@public/basic" /}
{block name="style"}{/block}
<link rel="stylesheet" href="__STATIC__/css/admin/public.css" media="all"/>
{block name="cotent"}
<form class="layui-form" style="width:80%;">
    <br>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">账号名称</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input" value="{$user.username|default=''}" readonly>
        </div>
    </div>

    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">初始密码</label>
        <div class="layui-input-block">
            <input type="password" name="old_password" class="layui-input old_password" lay-verify="old_password" lay-verify="required" placeholder="请输入初始密码">
        </div>
    </div>

    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">修改密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" class="layui-input password" lay-verify="password" lay-verify="required" placeholder="请输入修改密码">
        </div>
    </div>

    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-block">
            <input type="password" name="password1" class="layui-input password1" lay-verify="password1" lay-verify="required" placeholder="请输入确认密码">
        </div>
    </div>

    <input type="hidden" class="id" name="id" value="{$user.id|default=''}">

    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" id="editPassword">确定</button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
        </div>
    </div>
</form>
{/block}

{block name="script"}
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery;

        /**
         * 修改密码
         */
        $("#editPassword").click(function () {
            var data = {
                id: $(".id").val(),
                old_password: $(".old_password").val(),
                password: $(".password").val(),
                password1: $(".password1").val(),
            };
            $.request.post('{:url("$thisClass/edit_password")}', data, function (res) {
                $.msg.success(res.msg, function () {
                    $.tool.close();
                });
            });
            return false;
        })
    })
</script>
{/block}
